var path = require("path");
const chokidar = require("chokidar");
var fs = require("fs");
var dirs = [];
var pathName = "./src/components";
chokidar.watch("./src/components").on("change", (relativePath) => {
  console.log(666);
  fs.readdir(pathName, function (err, files) {
    var ruhse = [];
    files.map((a) => {
      if (a != "index.ts") {
        ruhse.push(a.split(".")[0]);
      }
    });
    let hkhge = "";
    ruhse.map((a) => {
      hkhge += `import ${a}s from "./${a}";
     export const ${a} = ${a}s;`;
    });
    fs.writeFile("./src/components/index.ts", hkhge, function (error) {
      console.log(error);
    });
  });
});
